How to Interface Nokia 5110 LCD with Arduino

In this article, we will learn to interface a compact and monochrome LCD display named Nokia 5110 with Arduino Nano. This article will also demonstrate how we can display alphanumeric characters, draw lines and other shapes and even display bitmap images after converting them into a data array via “Nokia 5110”.

Introduction of Nokia 5110 LCD Display:

Nokia 5110 is a low-powered, inexpensive, and easy-to-use LCD display module. This display features a low-powered CMOS LCD controller/driver called PCD8544. The PCD8544 is designed to drive a graphic array of 84×48 pixels (i.e. GDDRAM – Graphical Display Data RAM) which interfaces to microcontrollers via SPI protocol. This module is a good choice when it comes to battery-operated systems.

The display driver has a built-in GDDRAM  of 504 bytes. This memory area is organized into 6 banks (0 – 5) in row format, containing 84 columns/segments (0 – 83) so that each column can store 8 bits (0 – 7) of data. 

Mathematically :- 6 banks x 84 segments x 8 bits of data = 4032 bits = 504 bytes

memory arrangement of nokia 5110 displayFigure 1: Memory Arrangement of Nokia 5110 LCD Display

The Nokia 5110 LCD is popularly used to display beautiful graphical images and User Interface. These bitmap images are first converted into data arrays and then displayed.

Nokia 5110 LCD Display Specifications:

  • Operation Voltage : 2.7V – 3.3V (typically 3.3V)
  • Temperature range: −25 to +70 °C
  • Current consumption: 6mA
  • Pixel density: 84 ×48 pixels (monochrome)
  • Communication Method: SPI interface (MISO / MOSI)
  • Serial interface maximum 4.0 Mbits/s
  • Pixel Colour: Black
  • Dimension : 45mm × 45mm 

Application of Nokia 5110 LCD:

  • Used in applications where fancy graphics are required.
  • Comes with a backlight that can be adjusted via PWM signal and hence can be used in different lighting conditions.
  • Can be used to create retro games using microcontrollers.
  • Can be used to display alphanumeric characters and bitmap images (via data arrays) to create basic UI.

Pin Description of Nokia 5110 LCD Display

nokia 5110 lcd pin

  1. RST: This pin resets the module. It is an active low pin (resets when 0V is provided)
  2. CE: This pin is made low (0V) to select this particular display when more than one SPI peripheral are used.
  3. DC: This pin is used to switch between Data mode (high) and Command mode (low)
  4. DIN: This is the serial input pin (MOSI) through which serial instructions are sent
  5. CLK: The clock source is supplied to this pin.
  6. VCC: Input voltage from 2.7 to 3.3V.
  7. BL: This pin powers the backlight of the display (3.3V maximum).To control its brightness, you can add a potentiometer or connect this pin to any PWM-capable Arduino pin.
  8. GND: Ground pin (0V)

Nokia 5110 LCD with Arduino Wiring Diagram

How to Interface Nokia 5110 LCD with Arduino

The Pin connection between the LCD module and Nano can be understood easily from the following table:

arduino and nokia 5110 lcd pin connection

Software Code of Nokia 5110 LCD with Arduino and its Explanation:

Nokia 5110 LCD Display Library

Firstly, we will include all the following libraries which are required for this project. SPI.h will allow us to communicate through the SPI protocol. Whereas the other libraries (i.e. Adafruit_PCD8544.h and Adafruit_GFX.h) are required for the proper functionality of the Nokia 5510 LCD display. The “Adafruit_PCD8544.h” library is for operating the PCD8544-based Nokia display whereas “Adafruit_GFX.h” is the core graphics library that provides a common set of graphics primitives (points, lines, circles, etc.) for the Nokia display.

Initialise pins of Nokia5110 Display

Next, we will initialize the Nokia5110 display by creating an object of Adafruit_PCD8544 named “nDisplay”. We have connected Nokia 5510’s CLK, DIN, DC, CE, and RST pins to  Arduino digital pins: 13, 11, 6, 10, and 5 respectively.

Displaying Text on Nokia 5110 LCD Display with Arduino:

For displaying characters we have to set a few parameters

display.begin() = initialize the LCD display

setContrast() = It will set the contrast of the display. The “setContrast()” method takes in values between 0-100 but values from 50-60 give a good result. You can change the values and see what suits you better. Right now, we set the contrast to 57.

clearDisplay() = To clear the display (display buffer).

Similarly, in the text display command the fonts, size, and types can be adjusted. 

setTextSize() = To set the size of the text, we will use the “setTextSize()” method and pass the font size parameter inside it. Here we have set the font size as 1 (i.e. default), which denotes the smallest size. The characters are rendered in the ratio of 5:7. Meaning, passing font size 1 will render the text at 5×7 pixels per character, and passing font size 2 will render the text at 10×14 pixels per character, and so on.

setTextColor() = Next, we will control the color of the text by using the “setTextColor()” method and passing BLACK as an argument. If we have a dark background, we would have to set the display color parameter as “WHITE”.

setCursor() = We will use the “setCursor()” function to denote the x and the y-axis position from where the text should start. We have passed (0,0) as the parameter. The first parameter is the x-axis position that (+x) increases towards the right. The second parameter is the y-axis position that (+y) increases downwards.

println() = By using the “println()” method we will pass the text, that we want to display (i.e.  “|BEST|”) and set the cursor to the next line. Then re-adjusting the cursor to (0,10) to pass “|ENGINEERING|” and again set the cursor to (0,20) to pass “|PROJECTS|”. Then lastly set the cursor to (0,30) and pass the message “Nokia 5110” in an inverted font by providing two parameters to the “setTextColor()” method. This method will now set the “font color” and  “Background color” respectively. This is because of something called “function overloading” which enables the function implementation to change depending upon the parameters passed.

Finally, we will call the ”display()” method to display the passed text and symbols on the LCD screen.

Displaying Text on Nokia 5110 LCD Display with Arduino

Figure 4: Displaying Text on Nokia 5110 LCD Display with Arduino

Text Rotation in Nokia 5110 LCD Display

we can also rotate the text messages displayed on the LCD. The code is written within the Setup() function to invoke it once.

Here, the contents of the display can be rotated by using the “setRotation()” method. It allows you to view your display in portrait mode, or flip it upside down. The function accepts only one parameter which corresponds to only 1 out of 4 cardinal rotations. This value can be any non-negative integer starting from 0 up to 3. Each time you increase the value, the contents of the display are rotated 90 degrees anti-clockwise. 

  • 0 – Keeps the screen to the standard landscape orientation.
  • 1 – Rotate the screen 90° to the right.
  • 2 – Flip the screen upside down.
  • 3 – Rotate the screen 90° to the left.

Also, we can display ASCII symbols using the “write()” method which sends unique binary data to display according to the argument value. The display converts this binary data to ASCII text and displays corresponding symbols.

nokia 5110 lcd text rotation

Figure 5: Nokia 5110 LCD Text Rotation

Displaying Bitmap on Nokia 5110 LCD Display

To show a bitmap image on the Nokia 5110 LCD display, we need to call the “drawBitmap()” function. It takes six parameters (i.e. Top left corner X coordinate, top left corner Y coordinate, bitmap byte array, the width of bitmap in pixels, the height of bitmap in pixels, and Colour).  In our example, the bitmap image is 84×48 in size. So, X & Y coordinates are set to 0 while width & height is set to 84 & 48.

But, before we can call the drawBitmap() function, we first need to declare the data array of required bitmap images (converted by link: “https://javl.github.io/image2cpp/ ”) as a global variable. The call the array (i.e. Tomato) inside the drawBitmap() function.

When you declare the data array, you might want to store it inside the program memory (i.e. PROGMEM) instead of SRAM or Arduino as it provides better performance. The PROGMEM is primarily used for large chunks of data (an array mostly), which can overwhelm the SRAM (which is generally much smaller in size than the flash memory, but faster to access). The implication of storing something in PROGMEM is that it cannot be modified dynamically at runtime. Therefore, people generally use PROGMEM to store large immutable text or data.

Complete Code:

tomato image on nokia 5110 lcd

Figure 6: Tomato Image on Nokia 5110 LCD

marilyn monroe image on nokia 5110 lcd

Figure 7: Marilyn Monroe Image on Nokia 5110 LCD

Tips and Tricks for Working with Nokia 5110 LCD Display and Arduino:

  1. It is recommended to operate the NOKIA 5110 display module in 3.3V for a longer life span.
  2. The “setContrast()” method takes in values between 0-100 but values from 50-60 give a good result.

Leave a Comment